#include "Afx.h"
#include <opencv2/imgproc/imgproc_c.h>
#include <vector>
#include <map>

using namespace std;

void freeMat(float **mat, int row);


vector<CString> readFiles(CString fname);

void getAllFiles(CString &path, FILE *fp);

bool getMatApp4BF(CString fname, float **&mat, int &row, int &col);

void code4GlobalHistogram(float **dic, int dic_row, int dic_col, float ** mat, int row, int col, float *feature, int &dim);

void getImgFeature(IplImage * img, float ** dic, int dic_row, int dic_col, int mode, float *feature, int &feature_dim);

BOOL makeDir(CString dd);

vector<pair<float, int> > sortImg(IplImage * img, float ** dic, int dic_row, int dic_col, vector<int> &word_counts, int mode, float **index, int i_r, int top_k);

vector<pair<float, int> > sortImg2(IplImage * img, float ** dic, int dic_row, int dic_col, vector<int> &word_counts, int mode, float **mat, int mat_r, int mat_c, int top_k);

void loadRevertedIndex(CString &fname, float **&mat, int &row);

vector<int> loadInts(CString fn);

vector<CString> listFiles(CString dir);